VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsBusinessUnits"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

'Retrieves the business unit's PAYE reference number
Public Function GetPAYERefNumber(ByVal numComId As String, _
                                 ByVal sBusUnitCD As String) As String
On Error GoTo PROC_ERROR
    
    Dim sReturnValue As String
    
    Dim adoConn As ADODB.Connection
    Dim rsBusUnitDetails As ADODB.recordSet
    
    Dim adoComm As ADODB.Command
    
    
    
    
    
    
    Set adoConn = New ADODB.Connection
    With adoConn
        .CursorLocation = adUseClient
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    Set rsBusUnitDetails = New ADODB.recordSet
    With rsBusUnitDetails
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
    End With
    
    Set adoComm = New ADODB.Command
    With adoComm
        .CommandText = "dir_get_business_unit_details"
        .CommandType = adCmdStoredProc
        
        Set .ActiveConnection = adoConn
        .Parameters.Append .CreateParameter("com_id", adInteger, adParamInput, , numComId)
        .Parameters.Append .CreateParameter("buni_code", adVarChar, adParamInput, 6, sBusUnitCD)
    End With
        
    Set rsBusUnitDetails = adoComm.Execute
    
    If Not rsBusUnitDetails.EOF Then
        sReturnValue = rsBusUnitDetails.Fields("FUND_PAYE_REF_NUM").Value
    Else
        sReturnValue = ""
    End If
    
PROC_EXIT:
    'clean up
    rsBusUnitDetails.Close
    Set rsBusUnitDetails = Nothing
    adoConn.Close
    Set adoConn = Nothing
    
    GetPAYERefNumber = sReturnValue
    Exit Function
    
PROC_ERROR:
    sReturnValue = ""
    GoTo PROC_EXIT
    
End Function

